// pages/change/change.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
      itemList: [{
              name: '',
              text: '头像',
              head: true,
              events: 'changeHeadTap'
          },
          {
              name: '张三',
              text: '用户名/昵称',
              head: false,
              events: 'changeNameTap'
          },
          {
              name: '已验证',
              text: '手机号',
              head: false,
              events: 'changePhoneNumTap'
          },
      ],
      headImg: '/images/head.png',
      choseImg: true,
      changeName: true,
      text: ""
  },
  changePhoneNumTap() {
      wx.navigateTo({
          url: '/pages/bar/mine/persional/change/changePhoneNum/changePhoneNum',
      });
  },
  changeNameTap(e) {
      wx.navigateTo({
          url: '/pages/bar/mine/persional/change/changeName/changeName',
      });
  },
  input: function(e) {
      this.setData({ text: e.detail.value })
  },
  okTap(e) {
      const data = e.currentTarget.dataset;
      var list = this.data.itemList;
      list[1].name = this.data.text;
      this.setData({
          itemList: list,
          changeName: !this.data.changeName,
      });
  },
  changeHeadTap(e) {
      const data = e.currentTarget.dataset;
      this.setData({
          selected: data.index,
          choseImg: !this.data.choseImg,
      });
  },
  cancel(e) {
      const data = e.currentTarget.dataset;
      this.setData({
          choseImg: !this.data.choseImg,
      });
  },
  choseHeadTap() {
      var that = this;
      wx.chooseImage({
          count: 1, // 默认9 
          sizeType: ['original', 'compressed'],
          sourceType: ['album', 'camera'],
          success: function(res) {
              that.setData({
                  headImg: res.tempFilePaths
              })
          }
      })
  },
  onLoad: function(options) {},

});